﻿//using fabao.Cap;
using fabao.Common.Extensions.DependencyInjection;
using fabao.SqlSugar.Entities;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using Newtonsoft.Json;
//using fabao.IdGenerater.Yitter;

namespace Fabao.Shared.Domain
{
    public class BaseEntity : Entity<int>
    {
        //[SugarColumn(IsIgnore = true)]
        //[JsonIgnore]
        //public Lazy<IEventPublisher> EventPublisher => new(() =>
        //{
        //    //var httpContext = InfraHelper.Accessor.GetCurrentHttpContext();
        //    //if (httpContext is not null)
        //    //    return httpContext.RequestServices.GetRequiredService<IEventPublisher>();
        //    if (ServiceLocator.Provider is not null)
        //        return ServiceLocator.Provider.GetRequiredService<IEventPublisher>();
        //    throw new NotImplementedException(nameof(IEventPublisher));
        //});
    }

    public class BaseEntitySnow : EntityNotIdentity<long>
    {
        public BaseEntitySnow()
        {
            id = SnowFlakeSingle.Instance.NextId();
        }

        //[SugarColumn(IsIgnore = true)]
        //[JsonIgnore]
        //public Lazy<IEventPublisher> EventPublisher => new(() =>
        //{
        //    if (ServiceLocator.Provider is not null)
        //        return ServiceLocator.Provider.GetRequiredService<IEventPublisher>();
        //    throw new NotImplementedException(nameof(IEventPublisher));
        //});
    }
}
